<?php
/**
 * This file is part of the Agora distribution. 
 * Detailed copyright and licensing information can be found
 * in the gpl-3.0.txt file which should be included in the distribution.
 * 
 * @version		$Id: 3.0.14 Olympus 2010-09-28 rammstein4o $
 * @copyright  2007 - 2010 jVitals
 * @license   GPLv3 Open Source
 * @link       http://jvitals.com
 * @since      File available since initial release
 */
	defined ('IN_AGORA') or die;

	class AgoraPMSController extends AgoraController
	{
		function __construct()
		{
			parent::__construct();
			if ($this->agora_user['is_guest']) {
				Agora::showError('You cannot use PM');
				Agora::redirect(Agora::getRefferer());
			}

			if ($this->agora_config['o_pms_uddeim'] == '1') {
				
				$action = Agora::getVar('page');
				if (!$action)
				$action = Agora::getVar('action');
				
				$box = Agora::getVar('box');
				$send_to = Agora::getVar('send_to');

				if ($action == 'compose') {
					$task = 'new';
				} elseif ($box == '0') {
					$task = 'inbox';
				} elseif ($box == '1') {
					$task = 'outbox';
				} else {
					$task = '';
				}
				if ($task == 'new')
				{
                    $user_model = & Model::getInstance('UserModel');
                    $user = $user_model->load($send_to);
				    $url = Agora::makeURL(array('option'=>'com_uddeim','task'=>$task, 'recip'=>$user['jos_id']));
				}
				else $url = Agora::makeURL(array('option'=>'com_uddeim','task'=>$task));
				Agora::redirect($url);
			}
			$this->loadDefaultView();

          // MH - 20091025 - adding this to make sure PMs have access to smilies
          $smilies_model = & Model::getInstance('SmiliesModel');
          $smilies = $smilies_model->loadAll();

          $this->view->assignRef('smilies',$smilies);
          $this->view->assign('some_tabs_off',true);
		}
	}
?>
